#You need CUP v0.10j (or newer) for this makefile to work

JFLEX      = java -jar ../lib/JFlex.jar
CUP        = java -jar ../lib/java-cup-11a.jar -parser Parser -interface
JAVA       = java
JAVAC      = javac
JAVACFLAGS = 

# --------------------------------------------------

all: test

test: lexer-output.txt
	@(diff lexer-output.txt lexer-output.good && echo "Test OK!") || echo "Test failed!"

lexer-output.txt: compile
	$(JAVA) TestLexer TestLexer.java > lexer-output.txt


compile: scanner parser unicode
	$(JAVAC) $(JAVACFLAGS) Parser.java Scanner.java

parser: Parser.java

Parser.java: pdl++.cup
	$(CUP) pdl++.cup

scanner: Scanner.java

Scanner.java: pdl++.flex
	$(JFLEX) pdl++.flex

unicode: UnicodeEscapes.java

UnicodeEscapes.java: unicode.flex
	$(JFLEX) unicode.flex

clean:
	rm -f *.class
	rm -f *~
	rm -f Scanner.java
	rm -f Parser.java
	rm -f sym.java
	rm -f UnicodeEscapes.java
	rm -f lexer-output.txt
